package com.google.monkeyjump;

import java.util.ArrayList;
import java.util.List;

import android.app.Activity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

import com.google.monkeyjump.ranking.Rank;

class RankViewAdapter extends ArrayAdapter<Rank> {
	public RankViewAdapter(Activity context, int textViewResourceId) {
		super(context, textViewResourceId, new ArrayList<Rank>());
	}

	public RankViewAdapter(Activity context, int simpleListItem1,
			List<Rank> ranks) {
		super(context, simpleListItem1, ranks);
	}

	public View getView(int position, View convertView, ViewGroup parent) {
		View row = convertView;
		if (row == null) {
			LayoutInflater inflater = ((Activity) super.getContext()).getLayoutInflater();
			row = inflater.inflate(R.layout.row, null);
		}
		Rank rank = super.getItem(position);
		((TextView) row.findViewById(R.id.classification)).setText(rank.getClassification().name());
		((TextView) row.findViewById(R.id.points)).setText(String.valueOf(rank.getPoints()));
		((TextView) row.findViewById(R.id.user)).setText(rank.getUser());
		
		return (row);
	}

}
